using Circus.CodeEditor;

using System;
using System.ComponentModel;
namespace Circus.Syntax.CodeCompletion
{
	public class ListMember : IComparable
	{
		private string qualifier = string.Empty;
		private string paramText = string.Empty;
		private string name = string.Empty;
		private string displayText = string.Empty;
		private string description = string.Empty;
		private string dataType = string.Empty;
		private int overloads;
		private int memberType = -1;
		private int imageIndex = -1;
		private int currentParamIndex = -1;
		private int priority;
		private MemberAttribute attributes;
		private IParameterMembers parameters = null;
		private object customData = null;
		private ListMembers owner = null;
		public virtual string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if (this.name != value)
				{
					this.name = value;
					this.OnNameChanged();
				}
			}
		}
		public virtual string DisplayText
		{
			get
			{
				return (this.displayText != string.Empty) ? this.displayText : this.Name;
			}
			set
			{
				if (this.displayText != value)
				{
					this.displayText = value;
					this.OnDisplayTextChanged();
				}
			}
		}
		public virtual string DataType
		{
			get
			{
				return this.dataType;
			}
			set
			{
				if (this.dataType != value)
				{
					this.dataType = value;
					this.OnDataTypeChanged();
				}
			}
		}
		public virtual string Description
		{
			get
			{
				return (this.Owner != null && this.Owner.UseHtmlFormatting) ? this.description : this.description.Replace(SyntaxConsts.DefaultParaTag, string.Empty);
			}
			set
			{
				if (this.description != value)
				{
					this.description = value;
					this.OnDescriptionChanged();
				}
			}
		}
		public virtual string Qualifier
		{
			get
			{
				return this.qualifier;
			}
			set
			{
				if (this.qualifier != value)
				{
					this.qualifier = value;
					this.OnQualifierChanged();
				}
			}
		}
		public virtual int Overloads
		{
			get
			{
				return this.overloads;
			}
			set
			{
				if (this.overloads != value)
				{
					this.overloads = value;
					this.OnOverloadsChanged();
				}
			}
		}
		public virtual object CustomData
		{
			get
			{
				return this.customData;
			}
			set
			{
				if (this.customData != value)
				{
					this.customData = value;
					this.OnCustomDataChanged();
				}
			}
		}
		public virtual string ParamText
		{
			get
			{
				return this.GetParamText(true);
			}
			set
			{
				if (this.paramText != value)
				{
					this.paramText = value;
					this.OnParamTextChanged();
				}
			}
		}
		public virtual IParameterMembers Parameters
		{
			get
			{
				return this.parameters;
			}
			set
			{
				if (this.parameters != value)
				{
					this.parameters = value;
					this.OnParametersChanged();
				}
			}
		}
		public virtual int CurrentParamIndex
		{
			get
			{
				return this.currentParamIndex;
			}
			set
			{
				if (this.currentParamIndex != value)
				{
					this.currentParamIndex = value;
					this.OnCurrentParamIndexChanged();
				}
			}
		}
		public virtual int ImageIndex
		{
			get
			{
				return this.imageIndex;
			}
			set
			{
				if (this.imageIndex != value)
				{
					this.imageIndex = value;
					this.OnImageIndexChanged();
				}
			}
		}
		public virtual int MemberType
		{
			get
			{
				return this.memberType;
			}
			set
			{
				if (this.memberType != value)
				{
					this.memberType = value;
					this.OnMemberTypeChanged();
				}
			}
		}
		public virtual int Priority
		{
			get
			{
				return this.priority;
			}
			set
			{
				if (this.priority != value)
				{
					this.priority = value;
					this.OnPriorityChanged();
				}
			}
		}
		public virtual MemberAttribute Attributes
		{
			get
			{
				return this.attributes;
			}
			set
			{
				if (this.attributes != value)
				{
					this.attributes = value;
					this.OnAttributesChanged();
				}
			}
		}
		public virtual ListMembers Owner
		{
			get
			{
				return this.owner;
			}
			set
			{
				if (this.owner != value)
				{
					this.owner = value;
					this.OnOwnerChanged();
				}
			}
		}
	
		protected virtual void OnParamsChanged()
		{
		}
		protected virtual void OnNameChanged()
		{
		}
		protected virtual void OnDisplayTextChanged()
		{
		}
		protected virtual void OnDataTypeChanged()
		{
		}
		protected virtual void OnDescriptionChanged()
		{
		}
		protected virtual void OnQualifierChanged()
		{
		}
		protected virtual void OnOverloadsChanged()
		{
		}
		protected virtual void OnCustomDataChanged()
		{
		}
		protected virtual void OnParamTextChanged()
		{
		}
		protected virtual void OnParametersChanged()
		{
		}
		protected virtual void OnCurrentParamIndexChanged()
		{
		}
		protected virtual void OnImageIndexChanged()
		{
		}
		protected virtual void OnMemberTypeChanged()
		{
		}
		protected virtual void OnPriorityChanged()
		{
		}
		protected virtual void OnAttributesChanged()
		{
		}
		protected virtual void OnOwnerChanged()
		{
		}
		protected string JoinWithSpace(string s1, string s2)
		{
			return (s1 != string.Empty && s2 != string.Empty) ? (s1 + ' ' + s2) : ((s1 == string.Empty) ? s2 : s1);
		}
		protected string JoinWithSpace(string[] arr)
		{
			string text = string.Empty;
			for (int i = 0; i < arr.Length; i++)
			{
				string text2 = arr[i];
				if (text == string.Empty)
				{
					text = text2;
				}
				else
				{
					if (text2 != string.Empty)
					{
						text = text + ' ' + text2;
					}
				}
			}
			return text;
		}
		protected string RemoveStrings(string s, string[] arr, bool caseSensitive)
		{
			string text = s;
			for (int i = 0; i < arr.Length; i++)
			{
				string text2 = arr[i];
				int num = caseSensitive ? text.IndexOf(text2) : text.IndexOf(text2, StringComparison.OrdinalIgnoreCase);
				if (num >= 0)
				{
					text = text.Remove(num, text2.Length);
				}
			}
			return text;
		}
		public ListMember()
		{
		}
		public ListMember(ListMembers owner)
		{
			this.owner = owner;
		}
		public virtual string GetTemplate(bool addBase)
		{
			return this.Name;
		}
		public virtual string GetParamText(bool useFormatting)
		{
			string result;
			if (this.paramText != string.Empty)
			{
				result = this.paramText;
			}
			else
			{
				string text = string.Empty;
				if (this.Parameters != null)
				{
					foreach (IParameterMember current in this.Parameters)
					{
						string text2 = current.Text;
						if (text2 != string.Empty)
						{
							text += ((text == string.Empty) ? text2 : ("," + ' ' + text2));
						}
					}
				}
				result = ((text != string.Empty) ? ("(" + text + ")") : text);
			}
			return result;
		}
		public virtual void AddDescription(string text)
		{
			if (!(text == string.Empty))
			{
				if (this.description != string.Empty)
				{
					this.description = this.description + ((this.Owner != null && this.Owner.UseHtmlFormatting) ? SyntaxConsts.DefaultBrTag : "\r\n") + text;
				}
				else
				{
					this.description = text;
				}
			}
		}
		public virtual int CompareTo(object value)
		{
			if (value is ListMember)
			{
				return string.Compare(this.name, ((ListMember)value).Name, true);
			}
			throw new ArgumentException();
		}
	}
}
